package Runde2;

import java.util.*;

public class VO extends LVA implements VOInt {
	
	/**
	 * Creates new VO.
	 * 
	 * @param lvaNr Unique course number.
	 * @param title Title of the course.
	 * @param earliestReg Earliest date to register.  
	 * @param latestReg Latest date to register.
	 * @param deReg Latest date to deregister.
	 * @param maxMembers Maximum number of members (unlimited = Integer.MAX_VALUE). 
	 * @throws InvalidLVAException Numerous error cases (end of registration precedes its beginning, ...)
	 * 
	 */
	public VO(int lvaNr, String title, Person owner,
			GregorianCalendar earliestReg, GregorianCalendar latestReg,
			GregorianCalendar deReg, int maxMembers, ArrayList<Integer> predecessors, int[] requirements)
			throws InvalidLVAException {
		super(lvaNr, title, owner, earliestReg, latestReg, deReg, maxMembers, predecessors,
				requirements);
	}

	private HashMap<GregorianCalendar, Exam> exams = new HashMap<GregorianCalendar, Exam>();
	
	/**
	 * See: VOInt.java
	 */
	public void createExam(String pw, Person examiner, GregorianCalendar date, int lva, int max) throws InsufficientPermissionsException {
		try {
			exams.put(date, new Exam(examiner, lva, max, pw));
		} catch (InsufficientPermissionsException e) {
			throw new InsufficientPermissionsException(e.getMessage());
		}
	}

	public Exam getExam(GregorianCalendar date) throws IncorrectDateException {
		if (!exams.containsKey(date)) {
			throw new IncorrectDateException("This exam doesn't exist.");
		} else {
			return exams.get(date);
		}
	}
	
	
	
}